# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html

import requests
import os


class DyPipeline(object):

    def __init__(self):
        self.doc = os.mkdir('image')

    def process_item(self, item, spider):
        vertical_src = item['vertical_src']
        room_name = item['room_name']
        picture = requests.get(vertical_src).content
        with open('./image/%s.jpg'%room_name,'wb') as file:
            file.write(picture)
        return item
